from typing import List
from langchain_ollama import ChatOllama

def validate_user(user_id: int, addresses: List) -> bool:
    """Validate user using historical addresses.
    Args:
        user_id: (int) the user ID.
        addresses: Previous addresses.
    """
    return True

model = ChatOllama(
    model="glm4",
    temperature=0,
).bind_tools([validate_user])

#result = model.invoke("validate user_id=1, addresses=['china']")
#print(result)


import ollama

messages = [{'role': 'user', 'content': 'What is the weather in Toronto?'}]
tools = [{
    'type': 'function',
    'function': {
      'name': 'get_current_weather',
      'description': 'Get the current weather for a city',
      'parameters': {
        'type': 'object',
        'properties': {
          'city': {
            'type': 'string',
            'description': 'The name of the city',
          },
        },
        'required': ['city'],
      },
    },
}]

#response = ollama.chat(
#    model='glm4',
#    messages=messages,
#	# provide a weather checking tool to the model
#    tools=tools
#)


import openai
openai.base_url = "http://localhost:11434/v1/"
openai.api_key = 'ollama'

response = openai.chat.completions.create(
	model="llama3.1", # 'glm4 does not support tools
	messages=messages,
	tools=tools,
)




print(f"ContentString: {response.content}")
print(f"ToolCalls: {response.tool_calls}")

